package com.zpark.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.xml.ws.WebEndpoint;

/**
 * @PackageName: com.zpark.config
 * @ClassName: Swagger2Config
 * @Description:
 * @author: RZS
 * @date: 2023/5/12  8:54
 */
@Configuration // 声明当前类为配置类
@EnableSwagger2 // 开启Swagger功能
public class Swagger2Config {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zpark.controller")) // 扫描接口包路径
                .paths(PathSelectors.any()).build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("用户接口文档")
                .description("提供给前端开发人员的接口文档")
                .version("1.0")
                .contact(new Contact("大锤", "www.baidu.com", "132456@qq.com"))
                .build();
    }
}
